using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Turquoise.EntityGenerator.Models.Mapping
{
    public class ContentLanguageLineMap : EntityTypeConfiguration<ContentLanguageLine>
    {
        public ContentLanguageLineMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.ContentTitle)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(t => t.ContentDescription)
                .HasMaxLength(500);

            this.Property(t => t.ContentKeywords)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("ContentLanguageLine");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ContentId).HasColumnName("ContentId");
            this.Property(t => t.LanguageId).HasColumnName("LanguageId");
            this.Property(t => t.ContentTitle).HasColumnName("ContentTitle");
            this.Property(t => t.ContentDescription).HasColumnName("ContentDescription");
            this.Property(t => t.ContentKeywords).HasColumnName("ContentKeywords");
            this.Property(t => t.ContentDetail).HasColumnName("ContentDetail");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
            this.Property(t => t.UpdatedBy).HasColumnName("UpdatedBy");
            this.Property(t => t.PublishBeginDate).HasColumnName("PublishBeginDate");
            this.Property(t => t.PublishEndDate).HasColumnName("PublishEndDate");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");
            this.Property(t => t.IsApproved).HasColumnName("IsApproved");

            // Relationships
            this.HasRequired(t => t.Content)
                .WithMany(t => t.ContentLanguageLines)
                .HasForeignKey(d => d.ContentId);
            this.HasRequired(t => t.User)
                .WithMany(t => t.ContentLanguageLines)
                .HasForeignKey(d => d.CreatedBy);
            this.HasRequired(t => t.Language)
                .WithMany(t => t.ContentLanguageLines)
                .HasForeignKey(d => d.LanguageId);
            this.HasRequired(t => t.User1)
                .WithMany(t => t.ContentLanguageLines1)
                .HasForeignKey(d => d.UpdatedBy);

        }
    }
}
